package tech.treec.smartlight.callback;

import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttMessage;

/**
 * Created by Young on 2025/1/20.
 */
public class MqttCallBack implements MqttCallback {

    public MqttCallBack() {
    }

    /**
     * 连接异常断开回调此方法，可在此方法内做重连机制
     */

    @Override

    public void connectionLost(Throwable cause) {

/*SystemClock.sleep(10000);

MqttManager.getInstance().connect();*/

    }

    @Override

    public void messageArrived(String topic, MqttMessage message) throws Exception {
        String data = new String(message.getPayload(), "UTF-8");
        System.out.print("get mqtt msg:" +topic+":"+ data);
//        Object object = JSON.parse(data);
    }

    @Override

    public void deliveryComplete(IMqttDeliveryToken token) {

//        LogUtils.d(getClass().getSimpleName(), “token:”+token.toString());

    }

}
